package com.exp.clickdemo.lib;

import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;

import androidx.annotation.Nullable;

import com.exp.clickdemo.R;

public class ItemLayout extends LinearLayout {
    public ItemLayout(Context context) {
        this(context,null);
    }

    public ItemLayout(Context context, @Nullable AttributeSet attrs) {
        this(context, attrs,0);
    }

    public ItemLayout(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);

        LayoutInflater inflater = (LayoutInflater)   getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        inflater.inflate(R.layout.item_layout, this);

       setOnClickListener(new View.OnClickListener() {
            public void onClick(View v)
            {
                Log.i("xx", "click MyRelativeLayout");
            }
        });
        Log.i("xx", "MyLayout2 is clickable:" + isClickable());

        RelativeLayout rl = findViewById(R.id.rl);
        rl.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Log.i("xx", "click RelativeLayout");
            }
        });

        ImageView iv = findViewById(R.id.iv);
        iv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Log.i("xx", "click ImageView");
            }
        });
    }


}
